<div id="wrap">
	<div class="title"><?php echo $self['title']?></div>
	<div class="main">
		<div class="list">
			<div class="tt">
				<select id="zone">
				    <option value="0" selected>未处理列表</option>
				    <option value="1">已处理列表</option>
			    </select>
			</div>
			<ul id="page"></ul>
			<table class="content">
				<thead>
					<tr><th>地址</th><th>描述</th><th>申报人</th><th>联系电话</th><th>时间</th><th>操作</th></tr>
				</thead>
				<tbody id="tbody">

				</tbody>
			</table>
		</div>
	</div>
</div>
</body>
<script type="text/javascript">
  function ajax(url,fun){
  	let xmlhttp = new XMLHttpRequest();
  	xmlhttp.onreadystatechange = fun;
	xmlhttp.open("GET",url,true);
	xmlhttp.send();
  }
  let tbody = document.getElementById('tbody'),
      page = document.getElementById('page'),
      zone = document.getElementById('zone');
 
  ajax("gzwx_page.php?type="+zone.value,function() {
	    if(this.readyState==4 && this.status==200) {
	    	let data = JSON.parse(this.response);
	    	tbody.innerHTML = data.html;
	    	page.innerHTML = data.page;
	    	
	    }
  });
  zone.onchange = function(){
  	ajax("gzwx_page.php?type="+this.value,function() {
	    if(this.readyState==4 && this.status==200) {
	    	let data = JSON.parse(this.response);
	    	tbody.innerHTML = data.html;
	    	page.innerHTML = data.page;
	    }
  	});
  }
  page.onclick = function(e){
  	let href = e.target.getAttribute('href');
  	if(!/page=\d+/.test(href)){
  		return
  	}
  	ajax(href,function() {
	    if(this.readyState==4 && this.status==200) {
	    	let data = JSON.parse(this.response);
	    	tbody.innerHTML = data.html;
	    	page.innerHTML = data.page;
	    }
  	});
  	return false;
  }
  tbody.onclick = function(e){
  	let id = e.target.getAttribute('id'),
  	    msg = e.target.innerText;
  	if(!/^\d+$/.test(id)){
 		return
 	}
  	if(confirm(`您确定要${msg}吗?`)){
  	    let isdo = msg=='受理'? 1:0;
	  	ajax(`ud.php?type=7&id=${id}&isdo=${isdo}&s=wx`,function() {
		    if(this.readyState==4 && this.status==200) {
		    	let {res} = JSON.parse(this.response);
		      	if(res){
		      		window.location.reload();
		      	}
		    }
	  	});
  	}
  }
</script>
</html>